package com.yznote.cloudesk.manage.database.controller;

import com.yznote.cloudesk.common.Anno.CollectLogs;
import com.yznote.cloudesk.common.constants.ModuleConstant;
import com.yznote.cloudesk.common.pojo.Result;
import com.yznote.cloudesk.manage.database.pojo.Table;
import com.yznote.cloudesk.manage.database.service.DataBaseService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

@RestController
@CollectLogs(moduleName = ModuleConstant.DATABASE_MODULE)
@Api(value = "/数据库系统",description = "数据库系统")
@RequestMapping("/database")
public class DataBaseController {
    @Autowired
    DataBaseService dataBaseService;
    @ApiOperation("/获取数据库所有表名")
    @GetMapping("/getTables")
    public Result getTables(){
        List<String> strings = dataBaseService.selectTables();
        return Result.success(strings);
    }

    @ApiOperation("/获取数据库所有表的详细数据")
    @GetMapping("/getTablesAndDetail")
    public Result getTablesAndDetail(){
        List<Table> tables = dataBaseService.selectTablesAndDetail();
        return Result.success(tables);
    }
}
